using real identity for hashar
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageTrTest.php
1 <?php
2 /**
3 * @author Antoine Musso
4 * @copyright Copyright © 2011, Antoine Musso
5 * @file
6 */
7
8 /** Tests for MediaWiki languages/LanguageTr.php */
9 class LanguageTrTest extends MediaWikiTestCase {
10 private $lang;
11
12 function setUp() {
13 $this->lang = Language::factory( 'Tr' );
14 }
15 function tearDown() {
16 unset( $this->lang );
17 }
18
19 /**
20 * See @bug 28040
21 * Credits to #wikipedia-tr users berm, []LuCkY[] and Emperyan
22 * @see http://en.wikipedia.org/wiki/Dotted_and_dotless_I
23 * @dataProvider provideDottedAndDotlessI
24 */
25 function testDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
26 if( $func == 'ucfirst' ) {
27 $res = $this->lang->ucfirst( $input );
28 } elseif( $func == 'lcfirst' ) {
29 $res = $this->lang->lcfirst( $input );
30 } else {
31 throw new MWException( __METHOD__ . " given an invalid function name '$func'" );
32 }
33
34 $msg = "Converting $inputCase case '$input' with $func should give '$expected'";
35
36 $this->assertEquals( $expected, $res, $msg );
37 }
38
39 function provideDottedAndDotlessI() {
40 return array(
41 # function, input, input case, expected
42 # Case changed:
43 array( 'ucfirst', 'ı', 'lower', 'I' ),
44 array( 'ucfirst', 'i', 'lower', 'İ' ),
45 array( 'lcfirst', 'I', 'upper', 'ı' ),
46 array( 'lcfirst', 'İ', 'upper', 'i' ),
47
48 # Already using the correct case
49 array( 'ucfirst', 'I', 'upper', 'I' ),
50 array( 'ucfirst', 'İ', 'upper', 'İ' ),
51 array( 'lcfirst', 'ı', 'lower', 'ı' ),
52 array( 'lcfirst', 'i', 'lower', 'i' ),
53
54 # A real example taken from bug 28040 using
55 # http://tr.wikipedia.org/wiki/%C4%B0Phone
56 array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ),
57
58 # next case is valid in Turkish but are different words if we
59 # consider IPhone is English!
60 array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ),
61
62 );
63 }
64
65 }